package com.jeff.tianti.cms.dao;

import com.jeff.tianti.common.dao.CustomBaseSqlDaoImpl;
import com.jeff.tianti.common.entity.PageModel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jeff.tianti.cms.entity.Organization;
import com.jeff.tianti.cms.dto.OrganizationQueryDTO;
import org.apache.commons.lang3.StringUtils;

/**
 * @author NOW_GO
 * @desc OrganizationDaoImpl类 
 * @date 2019-07-12
 */

public class OrganizationDaoImpl extends CustomBaseSqlDaoImpl implements OrganizationDaoCustom  {

    public PageModel<Organization> queryOrganizationPage(OrganizationQueryDTO organizationQueryDTO){
         Map<String,Object> map = new HashMap<String,Object>();
         StringBuilder hql = new StringBuilder();
         hql.append("select t from Organization t where t.deleteFlag=0 ");
        if (organizationQueryDTO != null) {
            String organizeName = organizationQueryDTO.getOrganizeName();
            if (StringUtils.isNotBlank(organizeName)) {
                hql.append(" and t.organizeName = :organizeName ");
                map.put("organizeName", organizeName);
            }
        }
        hql.append(" order by t.createDate desc ");
         return this.queryForPageWithParams(hql.toString(),map,organizationQueryDTO.getCurrentPage(),organizationQueryDTO.getPageSize());
    }

    public List<Organization> queryOrganizationList(OrganizationQueryDTO organizationQueryDTO){
         Map<String,Object> map = new HashMap<String,Object>();
         StringBuilder hql = new StringBuilder();
         hql.append("select t from Organization t where t.deleteFlag=0 ");
         return this.queryByMapParams(hql.toString(),map);
    }


}